package com.sky.mapper;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.ReportDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface OrderMapper {

    //保存订单
    void insert(Orders orders);


    //条件查询
    List<Orders> list(OrdersPageQueryDTO queryDTO);

    //订单详情
    @Select("select * from orders where id=#{orderId}")
    Orders getById(Long orderId);

    //取消订单
    void update(Orders updateOrders);

    //根据状态统计订单数量
    @Select("select count(*) from orders where status=#{status}")
    Integer countByStatus(Integer toBeConfirmed);

    @Select("select * from orders where status = #{status} and order_time < date_sub(now(),interval #{minute} minute)")
    List<Orders> getByStatusAndOrderTime(Integer status, Integer minute);

    List<ReportDTO> turnoverStatistics(LocalDate localDate, LocalDate end, Integer completed);

}
